// version 1.0.2.6 by LJH @ 2017-04-24 (c)CETC15

#ifndef MTIME_H
#define MTIME_H

#include <QString>
#include <QDateTime>
#include <QRegExp>
#include <QMutex>
#include <QMutexLocker>
#include <QDebug>

#include "Windows.h"

class MTime : public QTime
{
public:
    MTime();
    MTime(int h, int m = 0, int s = 0, double ms = 0 );
    MTime(const QTime& time);
    MTime(const MTime& time);

    void setHMS(int h, int m, int s, double ms);

    MTime addMSecs(double ms) const;
    MTime addSecs(int secs) const;

    double getInteralMsVal();

    int usec();
    int nsec();
    qint64 usecTo(const MTime& t);
    qint64 nsecTo(const MTime& t);

    QString toString(const QString & format) const;

    void start();
    void restart();
    double elapsed();
    static void sleep(double ms=1.0);

    bool operator!= ( const MTime & t ) const;
    bool operator<  ( const MTime & t ) const;
    bool operator<= ( const MTime & t ) const;
    bool operator== ( const MTime & t ) const;
    bool operator>  ( const MTime & t ) const;
    bool operator>= ( const MTime & t ) const;
private:
    LONGLONG QPart1;
    double m_ms;
};

#endif // MTIME_H
